/*
 * @LastEditors: 七七
 * @Date: 2023-01-08 14:00:38
 *
 * 该文件专门为Count组件生成action对象
 */

import { INCREMENT, DECREMENT } from "../constant";

// todo object同步action function异步action

// ! 同步action，指action的值为object类型的一般对象
export const increment = (data) => ({ type: INCREMENT, data }); //object
export const decrement = (data) => ({ type: DECREMENT, data });
// ! 异步action，指action的值为函数，异步action中一般都会调用同步action
export const incrementAsync = (data, time) => {
  return (dispatch) => {
    setTimeout(() => {
      // 通知redux加data
      dispatch(increment(data));
    }, time);
  }; //function
};
